﻿<%@ Page Title="PostBack & Server Events" Language="C#" MasterPageFile="~/Demo.master"
    Inherits="DemoPage" StylesheetTheme="humanity" %>

<%@ Register Src="~/CodeFormatter.ascx" TagName="Code" TagPrefix="demo" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            MailBoxView.Items[0].Data = "Text in data";
            MailBoxView.Items[1].Data = true;
            MailBoxView.Items[2].Data = 123;
        }
    }

    protected void Nav1_NavItemClick(object sender, NavItemEventArgs e)
    {
        if (e.Item != null)
        {
            txtText.Text = e.Item.Text;
            if (e.Item.Data != null)
                txtData.Text = e.Item.Data.ToString();
        }
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="DemoHolder" runat="Server">
    <div class="dna-state-info ui-corner-all" style="margin-bottom: 10px;">
        Set <b>AutoPostBack</b> to true and set and event handler to <b>OnNavItemClick</b>
        server event to handling the NavItemClick event.
        <p>
            BTW you can using the <b>Data</b> property to puts the data what you need in to
            the item.</p>
    </div>
    <br />
    <table>
        <tr>
            <td valign="top">
                <DotNetAge:Accordion ID="Accordion1" runat="server" AutoHeight="false" Width="300">
                    <Views>
                        <DotNetAge:NavView ID="MailBoxView" runat="server" Text="Mail" CssClass="dna-ui-navview"
                            ShowItemIcon="true" OnNavItemClick="Nav1_NavItemClick" AutoPostBack="true">
                            <Items>
                                <DotNetAge:NavItem Text="InBox" />
                                <DotNetAge:NavItem Text="OutBox" />
                                <DotNetAge:NavItem Text="SendBox" />
                            </Items>
                        </DotNetAge:NavView>
                        <DotNetAge:NavView ID="NavView1" runat="server" Text="Contacts" AutoPostBack="true"
                            OnNavItemClick="Nav1_NavItemClick">
                            <Items>
                                <DotNetAge:NavItem Text="All Contacts" />
                                <DotNetAge:NavItem Text="Persional" />
                            </Items>
                        </DotNetAge:NavView>
                    </Views>
                </DotNetAge:Accordion>
            </td>
            <td valign="top">
                <div>
                    <div class="ui-state-active ui-corner-top" style="height: 25px; padding: 3px; vertical-align: middle;">
                        Selected Item
                    </div>
                    <div id="exampleDiv" class="ui-widget-content ui-corner-bottom" style="padding: 10px;">
                        Item Text:
                        <div>
                            <asp:TextBox ID="txtText" runat="server"></asp:TextBox>
                        </div>
                        Item Data:
                        <div>
                            <asp:TextBox ID="txtData" runat="server"></asp:TextBox>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <br />
    <demo:Code runat="server" ID="codeView" SourceFile="~/Accordion/Codes/NavViewPostBack.aspx" />
</asp:Content>
